package com.suoluo.zenadmin.common.file;

import com.suoluo.zenadmin.common.config.SystemConfigHolder;



public class FileEntry {

	private String filePreffix;
	
	private String fileName;
	
	private String filePath;

	public FileEntry(String filePreffix, String fileName) {
		super();
		this.filePreffix = filePreffix;
		this.fileName = fileName;
	}
	
	public FileEntry(String filePath){
		int fileNameIndexStart = filePath.lastIndexOf("/");
		this.filePreffix = filePath.substring(0, fileNameIndexStart + 1);
		this.fileName = filePath.substring(fileNameIndexStart + 1);
	}

	public String getFilePreffix() {
		return filePreffix;
	}

	public void setFilePreffix(String filePreffix) {
		this.filePreffix = filePreffix;
	}

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public String getFilePath() {
		return this.filePreffix + this.fileName;
	}

	public String getMiniFilePath(){
		return this.filePreffix + SystemConfigHolder.getMiniImgPreffix() + this.fileName;
	}
	/**
	 * 生成小图片路径
	 * @param preffix 图片前缀
	 * @param miniPreffix 小图片前缀
	 * @param fileName 图片名称
	 * @return
	 */
	public static String getMiniFilePath(String preffix,String miniPreffix,String fileName)
	{
		return preffix+miniPreffix+fileName;
	}
//	public static void main(String []args){
//		String filePath = "/news/1232/2222.jpg";
//		FileEntry entry = new FileEntry(filePath);
//		System.out.println(entry.getFileName());
//		System.out.println(entry.getFilePreffix());
//	}
//	
}
